package nl.scalasim

import java.util.logging.{LogManager, Logger}

/**
 * Simple logging trait.
 *
 * @author Yigal Duppen
 * @since Oct 26, 2010
 */
trait Logging {

  val log: Logger = Logger.getLogger(this.getClass.getSuperclass.getName)

}


object Logging {

  private var initialized = false

  def do_init: Unit = {
    val in = getClass.getResourceAsStream("/logging.properties")
    try {
      LogManager.getLogManager.readConfiguration(in);
    }
    finally {
      in.close()
    }
  }

  def init() {
    if (!initialized) {
      do_init
    }
    initialized = true
  }

}